package org.fin.session;

import org.dom4j.DocumentException;
import org.fin.config.ConfigurationBuilder;
import org.fin.pojo.Configuration;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {

  public SqlSessionFactory build(InputStream in) throws PropertyVetoException, DocumentException {
    // 1. 使用dom4j解析配置文件，将解析出来的内容封装到Configuration
    Configuration configuration = new ConfigurationBuilder().parseConfig(in);


    // 2. 创建SqlSessionFactory
    return new DefualtSqlSessionFactory(configuration);
  }
}
